home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 18 / CU Amiga Magazine's Super CD-ROM 18 (1997)(EMAP Images)(GB)[!][issue 1998-01].iso / CUCD / Programming / AmigaE / Src / OOmodules / Coordinate / polylinewin.e < prev   
Encoding:
Text File  |  1997-04-19  |  1.7 KB  |  95 lines

  1. /*
  2.  
  3. Just draws some circle. Remove the Delay() and the second Plot() to
  4. see its speed :)
  5.  
  6. */
  7.  
  8. OPT PREPROCESS
  9.  
  10. MODULE 'oomodules/coordinate', 'oomodules/coordinate/polyline'
  11.  
  12. #define NULL_X (200)
  13. #define NULL_Y (100)
  14.  
  15. DEF lastx=0,lasty=0,firstelement,polycolour
  16.  
  17. PROC main()
  18. DEF win, coo:PTR TO coordinate,count,co2:PTR TO coordinate,
  19.     polyline:PTR TO polyline, co3:PTR TO coordinate,
  20.     co4:PTR TO coordinate
  21.  
  22.   NEW coo.new(["set",50.0,50.0,0.0])
  23.   NEW co2.new(["set",0.0,-50.0,25.0])
  24.   NEW co3.new(["set",-35.0,35.0,0.0])
  25.   NEW co4.new(["set",50.0,50.0,0.0])
  26.  
  27.   NEW polyline.new()
  28.  
  29.   polyline.add(coo)
  30.   polyline.add(co2)
  31.   polyline.add(co3)
  32.   polyline.add(co4)
  33.  
  34.   win := OpenW(0,0,400,200,0,$F,'ui',0,1,0,0)
  35.  
  36.  
  37.   Line(NULL_X-100, NULL_Y, NULL_X+100, NULL_Y)
  38.   Line(NULL_X, NULL_Y-50, NULL_X, NULL_Y+50)
  39.  
  40.  
  41.   FOR count:=0 TO 180*5
  42.  
  43.     firstelement:=TRUE
  44.  
  45.     polycolour:=1
  46.     polyline.coordinates.do({draw}) -> draw it
  47.  
  48.     Delay(1)
  49.     WaitTOF()
  50.     polycolour:=0
  51.     polyline.coordinates.do({draw}) -> delete it
  52.  
  53.     polyline.coordinates.do({rotate}) -> rotate it
  54.   ENDFOR
  55.  
  56.   Delay(150)
  57.  
  58.   CloseW(win)
  59.  
  60. ENDPROC
  61.  
  62. PROC drawline (x,y,x2,y2,colour=1)
  63.  
  64.     Line(NULL_X+(x/2),NULL_Y+(y/4),
  65.          NULL_X+(x2/2)  ,NULL_Y+(y2/4),colour)
  66.  
  67. ENDPROC
  68.  
  69.  
  70. PROC draw(obj:PTR TO coordinate)
  71. DEF nux,nuy
  72.  
  73.   nux:=!obj.getX()!
  74.   nuy:=!obj.getY()!
  75.  
  76.  /*
  77.   * The flag is deleted when we process the first element. Since each
  78.   * line begins where the last line ended we can't draw the first one...
  79.   */
  80.  
  81.   IF firstelement=TRUE
  82.     firstelement := FALSE
  83.   ELSE
  84.     drawline(lastx,lasty, nux, nuy,polycolour)
  85.   ENDIF
  86.  
  87.   lastx:=nux
  88.   lasty:=nuy
  89. ENDPROC
  90.  
  91. PROC rotate(obj:PTR TO coordinate)
  92.  
  93.   obj.rotateY(2.0)
  94. ENDPROC
  95.